package com.umer.pinban.adapter.customer;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.common.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.common.ui.recycleview.base.ViewHolder;
import com.common.ui.recycleview.listener.DataStateListener;
import com.common.ui.recycleview.listener.OptListener;
import com.umer.pinban.R;
import com.umer.pinban.bean.customer.TipListBean;
import java.util.List;

public class TipsRecordAdapter extends RecyclerviewBasicAdapter<TipListBean> {

    private OptListener optListener;

    public TipsRecordAdapter(Context context, List<TipListBean> datas, int layoutId,
                             OptListener optListener, DataStateListener dataStateListener) {
        super(context, datas, layoutId,dataStateListener);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final TipListBean bean, final int position) {
        TextView tv_date = holder.getView(R.id.tv_date);
        TextView tv_staff_name = holder.getView(R.id.tv_staff_name);
        TextView tv_content = holder.getView(R.id.tv_content);
        ImageView iv_edit = holder.getView(R.id.iv_edit);
        ImageView iv_delete = holder.getView(R.id.iv_delete);
        iv_edit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
        iv_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
        String remindDate = bean.getRemindDate();
        String personnelName = bean.getPersonnelName();
        String remark = bean.getRemark();
        if(remindDate!=null && !remindDate.equals("") && !remindDate.equals("null")){
            tv_date.setText(remindDate.replace("00:00:00",""));
        }else {
            tv_date.setText("");
        }

        if(personnelName!=null && !personnelName.equals("") && !personnelName.equals("null")){
            tv_staff_name.setText(personnelName);
        }else {
            tv_staff_name.setText("");
        }

        if(remark!=null && !remark.equals("") && !remark.equals("null")){
            tv_content.setText(remark);
        }else {
            tv_content.setText("");
        }
    }
}
